package com.ymq.reggie.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ymq.reggie.common.BaseContext;
import com.ymq.reggie.entity.ShoppingCart;
import com.ymq.reggie.mapper.ShoppingCartMapper;
import com.ymq.reggie.service.ShoppingCartService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class ShoppingCartServiceImpl extends ServiceImpl<ShoppingCartMapper, ShoppingCart> implements ShoppingCartService {
    @Autowired
    private ShoppingCartService shoppingCartService;
    //清空购物车
    @Override
    public void cleanShoppingCatr() {
        Long threadLocalId = BaseContext.getThreadLocalId();
        LambdaQueryWrapper<ShoppingCart> shoppingCartLambdaQueryWrapper = new LambdaQueryWrapper<>();
        shoppingCartLambdaQueryWrapper.eq(ShoppingCart::getUserId,threadLocalId);
        shoppingCartService.remove(shoppingCartLambdaQueryWrapper);
    }
}
